#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    int numbers[20];
    int counts[20] = {};
    int max_count = 1;
    int max_count_address = 0;
    int size = 0;
    cin >> size;
    for (int i = 0; i < size; i++)
    {
        cin >> numbers[i];
    }
    for (int i = 0; i < size; i++)
    {
        int count = 1;
        while (numbers[i] == numbers[i + 1])
        {
            count++;
            i++;
        }
        counts[i] = count;
    }
    for (int i = 0; i < size; i++)
    {
        if (counts[i + 1] > max_count)
        {
            max_count = counts[i + 1];
            max_count_address = i + 1;
        }
    }

    cout << numbers[max_count_address] << endl;
    return 0;
}